{include file="public/header"/}

<div id="container" style="overflow-y: auto;">
    <div class="col-lg-12">
        <h2 class="page-header" style="font-size: 20px;"><i class="am-icon-gear"></i>  我的设置</h2>
    </div>   

    <div style="margin-left: 5%">

        <div style="margin-top: 20px;">

            {if $video == 'open'}
            <h4>设置是否关闭视频通话</h4>
            <div style="margin-top: 10px;">
                <button class="am-btn am-btn-success" onclick="getswitch('close')">点击关闭视频</button>
            </div>
            {else}
            <h4>设置是否开启视频通话</h4>
            <div style="margin-top: 10px;">
                <button class="am-btn am-btn-success" onclick="getswitch('open')">点击开启视频</button>
            </div>

            {/if}
        </div>


        <div style="margin-top: 20px;">

            {if $voice == 'open'}
            <h4>设置是否关闭消息提醒</h4>
            <div style="margin-top: 10px;">
                <button class="am-btn am-btn-success" onclick="getswitchvoice('close')">点击关闭提示音</button>
            </div>
            {else}
            <h4>设置是否开启消息提醒</h4>
            <div style="margin-top: 10px;">
                <button class="am-btn am-btn-success" onclick="getswitchvoice('open')">点击开启提示音</button>
            </div>
            {/if}
        </div>

        <div style="margin-top: 20px;">
            
             <h4>更改提示音</h4>
               
               <div class="layui-form-item" style="width: 60%;position: relative;margin: 10px;">
                    <form id="voiceform" class="am-form am-form-xs" style="position: absolute;right: 80px;" method="post">
                        <div class="am-form-group am-form-file">
                            <div style="height: 100%">
                                <button type="button" class="am-btn am-btn-default am-btn-sm" style="height: 39px;">选择音频文件</button>
                                <input type="file" name="voice" id="voice"  onchange='putfile()' multiple>
                            </div>
                        </div>
                     </form>
                    <input type="text" id='show' value="" class="layui-input">
                    <input class="layui-btn" type='submit' style="position:absolute;right: 0px;top:0px;width: 80px" onclick="getchange()" value="提交">
              </div>
           
        </div>
        
    </div>
       


 </div>


<script type="text/javascript">


    var putfile=function(){
          var v = $("#voice").val();
          $("#show").val(v);

         
    }


    var getchange =function(){

          $("#voiceform").ajaxSubmit({
            url: '{:url("admin/manager/uploadvoice")}',
            type: "post",
            dataType:'json',
            success: function (res) {
                   if(res.code == 0){
                      layer.msg(res.msg,{icon:1});
                   }else{
                     layer.msg(res.msg,{icon:2});
                   }

            }
        });

    }



    var getswitch =function(res){

        $.ajax({
            url:'/admin/set/videoswitch',
            type:'post',
            dataType:'json',
            data:{type:res},
            success:function(res){
                if(res.code == 0){
                    layer.msg(res.data,{icon:1,end:function(){
                        location.reload();
                    }});
                }else{
                    layer.msg(res.data,{icon:2,end:function(){
                        location.reload();
                    }});
                }
            }
        })
    }


    var getswitchvoice =function(res){

           $.ajax({
            url:'/admin/set/voiceswitch',
            type:'post',
            dataType:'json',
            data:{type:res},
            success:function(res){
                if(res.code == 0){
                    layer.msg(res.data,{icon:1,end:function(){
                        location.reload();
                    }});
                }else{
                    layer.msg(res.data,{icon:2,end:function(){
                        location.reload();
                    }});
                }
            }
        })

    }
    
</script>

{include file="public/footer"/}


